<!DOCTYPE html>
<html lang="zh-CN">
  <head>
	  <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'添加', styles:'bootstrap,font-awesome,animate,style,dtvalidate,layui,cxwebuploader,cxuploader'}){%>
	  <style type="text/css">
		  body{padding-top:10px;}
		  .radio{
			  vertical-align:middle;
			  margin-top:5px;
		  }
	  </style>
	  <%}%>
  </head>
  <body>
  <div class="wrapper wrapper-content">
	  <div class="row">
		  <div class="col-sm-12">
			  <div class="col-sm-offset-1 col-sm-10" style="margin-left: -10px;width: 100%;">
				  <button type="button" class="return-btn btn btn-w-m btn-primary">返回</button>
				  <div style="border-color: #e7eaec;border-image: none;border-style: solid solid none;border-width: 4px 0px;padding-bottom: 15px;margin-top: 10px;" ></div>
			  </div>
		  </div>
	  </div>
  </div>
	<!-- START 内容部分 -->
	<div class="container">
		<form class="form-horizontal" id="info-form" method="post" autocomplete="off">
			<input type="hidden" id="id" name="id" value="${supplier.id}" class="form-control" />
			<div class="form-group">
				<label class="col-sm-2 control-label text-right">供应商简称:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierName" name="supplierName" value="${supplier.supplierName}" class="form-control" />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">供应商全称:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierFullName" name="supplierFullName" value="${supplier.supplierFullName}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">供应商地址:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierAddress" name="supplierAddress" value="${supplier.supplierAddress}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">负责人:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierMan" name="supplierMan" value="${supplier.supplierMan}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">联系电话:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierPhone" name="supplierPhone" value="${supplier.supplierPhone}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">备注:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierNotes" name="supplierNotes" value="${supplier.supplierNotes}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">账期:</label>
				<div class="col-sm-8">
					<input type="text" id="supplierDay" name="supplierDay" onkeyup="value=value.replace(/[^\d\.]/g,'')"  value="${supplier.supplierDay}" class="form-control"  />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-sm-2">国内仓:</label>
				<div class="col-sm-8">
					<select id="supplierWare" name="supplierWare" class="form-control">
						<option value="否" selected>否</option>
						<option value="是" >是</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="save-btn btn btn-primary">
						<i class="fa fa-save"></i> 保存
					</button>
				</div>
			</div>
		</form>
	</div>
	<!-- END 内容部分 -->
  </div>
	<!-- START 公共脚本 -->
    <%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn,laydate,layer,cxuploaders,cxuploader7'}){}%>
	<!-- END 公共脚本 -->

	<script>
	var cvalidator;
	$(function(){
		//初始化验证器
		cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
		//提交表单
		$('.save-btn').on('click',function(){

			var supplierName=$("#supplierName").val();
			if(supplierName=='') {
				parent.layer.msg('请填写供应商简称！', {icon: 0, time: 1500, shade: [0.8, '#393D49']});
				return;
			}
			//数据提交
			$.post('/sea/supply/supplier/usave.do',$('#info-form').serialize(),function(data){
				if( data.ok ){
					parent.layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']}, function(){
						parent.$supplierTable.bootstrapTable('refresh');
						parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
					});
				}else{
					parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
				}
			});
		});
    });


	$("#productBigClassId").change(function () {
		var parentId=$("#productBigClassId").val();
		getCategory(parentId,1);
	});
	$("#productMidClassId").change(function () {
		var parentId=$("#productMidClassId").val();
		getCategory(parentId,2);
	});

	function getCategory(parentId,type) {
		$.ajax({
			url:'/sea/product/category/findByParentId',
			data:{
				id:parentId
			},
			type:'post',
			success:function (data) {
				var list=data;
				if(list.length>0){
					var category='<option value="">全部分类</option>';
					for(var i=0;i<list.length;i++){
						category+='<option value="'+list[i].id+'">'+list[i].categoryName+'</option>';
					}
					if(type=='1') {
						$("#productMidClassId").html(category);
					}
					if(type=='2'){
						$("#productClassId").html(category);
					}
				}
			}
		});
		//返回

	}
	$('.return-btn').on('click',function(){
		parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
	});
    </script>
  </body>
</html>